package com.zdp.test.proxy.cglibproxy;

import net.sf.cglib.proxy.Enhancer;

/**
 * @describte:Cglib代理类工厂
 * @program:ThoughtTest
 * @author:zhengdp
 * @create:2021-12-25 21:12:12
 **/
public class CglibProxyFactory {

    public static <T> T getProxyObject(T target){
        Enhancer enhancer = new Enhancer();
        CglibProxyMehtodInvocation cglibProxyMehtodInvocation = new CglibProxyMehtodInvocation(target);
        enhancer.setCallback(cglibProxyMehtodInvocation);
        enhancer.setSuperclass(target.getClass());
        return (T)enhancer.create();
    }

}
